package com.coke.demo.service.impl;

import com.coke.demo.mapper.LabMapper;
import com.coke.demo.model.Laboratory;
import com.coke.demo.service.LabService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @author 19602
 */
@Service
public class LabServiceImpl implements LabService {

    private LabMapper labMapper;

    @Autowired
    public void setLabMapper(LabMapper labMapper) {
        this.labMapper = labMapper;
    }

    /**
     * 查询所有实验室信息
     *
     * @return List<Laboratory>
     */
    @Override
    public List<Laboratory> findAllLabs() {
        return labMapper.findAllLabs();
    }

    /**
     * 根据id删除实验室
     *
     * @param labid :实验室id
     * @return true
     */
    @Override
    public Boolean deleteLabById(Integer labid) {
        return labMapper.deleteLabById(labid);
    }

    /**
     * 根据id查询实验室信息
     *
     * @param labid 实验室id
     * @return Laboratory
     */
    @Override
    public Laboratory findLabById(Integer labid) {
        return labMapper.findLabById(labid);
    }

    /**
     * 根据名称查询实验室信息
     *
     * @param labname 实验室名称
     * @return Laboratory
     */
    @Override
    public ArrayList<Laboratory> findLabByName(String labname) {
        return labMapper.findLabByName(labname);
    }

    /**
     * 根据id修改实验室信息
     *
     * @param laboratory 新的实验室信息
     * @return true
     */
    @Override
    public Boolean updateLabById(Laboratory laboratory) {
        return labMapper.updateLabById(laboratory);
    }

    /**
     * 根据实验室名称查询实验室信息
     *
     * @param labname 实验室名称
     * @return laboratory
     */
    @Override
    public Laboratory findByLabName(String labname) {
        return labMapper.findByLabName(labname);
    }

    /**
     * 添加新的实验室
     *
     * @param laboratory 实验室信息
     * @return Laboratory
     */
    @Override
    public Boolean insertLab(Laboratory laboratory) {
        return labMapper.insertLab(laboratory);
    }
}
